<?php

namespace app\common\controller;

use app\common\library\Auth;
use think\Config;
use think\Controller;
use think\Hook;
use think\Lang;

/**
 * 前台控制器基类
 */
class Frontend extends Controller
{
    public function _initialize()
    {
        parent::_initialize();

        $foreign_id = null;
        $model = model('Click');
        $param = $this->request->param();
        $controller = $this->request->controller();
        if ($controller == 'Category' || $controller == 'Article'){
            if ($controller == 'Category'){
                $foreign_id = $param['cid'];
                $type = 1;
            }else if ($controller == 'Article'){
                $foreign_id = $param['aid'];
                $type = 2;
            }
            $data = [
                'type'          => $type,
                'foreign_id'    => $foreign_id,
                'ip'            => get_proxy_ip(),
                'time'          => time()
            ];
            $model->save($data);
        }

    }



}
